package com.example.demo.redis.service.impl;

import com.example.demo.model.Material;
import com.example.demo.redis.mapper.RedisTestMapper;
import com.example.demo.redis.repository.RedisTestRepository;
import com.example.demo.redis.repository.RedisZhuJieRepository;
import com.example.demo.redis.service.RedisTestService;
import com.example.demo.util.Result;
import com.example.demo.util.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 86151 on 2018/12/27.
 */
@Service
public class RedisTestServiceImpl implements RedisTestService {

    @Autowired
    private RedisTestRepository redisTestRepository;

    @Autowired
    private RedisZhuJieRepository redisZhuJieRepository;

    @Override
    public Result<Material> queryMaterialById(Integer id) {

        return redisZhuJieRepository.queryMaterialById(id);
    }

    @Override
    public Result<List<Material>> deleteRedis(Integer id) {
        redisZhuJieRepository.delete(id);
        return null;
    }

    @Override
    public Result<List<Material>> updateRedis(Material material) {
        List<Material> materials = new ArrayList<>();
        redisZhuJieRepository.updateRedis(material);
        return ResultVo.success(materials);
    }
}
